package com.changyi.device.swipe;

import android.content.Context;

import com.changyi.device.DeviceConstant;

public class ReadCardManager {

    public static ReadCardInterface initReadCard(Context context, String printerTypeStr) {
        int printerType = deviceModelInit(printerTypeStr);
        ReadCardInterface readCardInterface = A8Card.getInstance(context);//默认A8
        switch (printerType){
            case DeviceConstant.LANDI_A8:{
                readCardInterface = A8Card.getInstance(context);
            }
            break;

            case DeviceConstant.SUNMI_P2:{
                readCardInterface = SunmiP2Card.getInstance(context);
            }
            break;
            default:
                readCardInterface = A8Card.getInstance(context);
        }
        return readCardInterface;
    }

    private static int deviceModelInit(String printerTypeStr) {
        int deviceMode =  DeviceConstant.LANDI_A8;
        if(printerTypeStr.contains("HI98")){
            deviceMode = DeviceConstant.HISENSE_HI98;
        }else if(printerTypeStr.contains("M2")){
            deviceMode =  DeviceConstant.ZQ_M2;
        }else if(printerTypeStr.contains("P2")){
            deviceMode = DeviceConstant.SUNMI_P2;
        }
        else{
            deviceMode =  DeviceConstant.LANDI_A8;
        }
        return deviceMode;
    }
}
